﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using ZoneFiveSoftware.Common.Visuals;
using ZoneFiveSoftware.Common.Visuals.Fitness;
using SportTracksPluginFramework;
using DistributionPlugin.Controller;

namespace DistributionPlugin.View
{
    class DistributionDetailsPage : STFrameworkDetailPage
    {
        public DistributionDetailsPage(IDailyActivityView dailyActivityView)
        {
            m_DailyActivityView = dailyActivityView;
        }

#region STFrameworkDetailPage members

        public override System.Windows.Forms.Control DetailPageControl
        {
            get
            {
                if (m_Control == null)
                {
                    ActivityDetailsOptions optionsInstance = ActivityDetailsOptions.DailyActivityInstance;

                    // Use the reports view options
                    if (m_DailyActivityView.GetType().FullName.Contains("ActivityReportDetailsPage"))
                    {
                        optionsInstance = ActivityDetailsOptions.ReportsActivityInstance;
                    }

                    m_Control = new DistributionDetailsControl(this, m_DailyActivityView, optionsInstance);
                    m_Control.DetailPageVisible = m_Visible;
                }

                return m_Control;
            }
        }

        public override bool HidePage()
        {
            if (m_Control != null)
            {
                m_Control.DetailPageVisible = false;
            }
            m_Visible = false;

            return true;
        }

        public override Guid Id
        {
            get { return GUIDs.DistributionDetailsPage; }
        }

        public override ExtendViewDetailPages.Location Location
        {
            get { return ExtendViewDetailPages.Location.LeftDetail; }
        }

        public override Guid MainPluginId
        {
            get { return GUIDs.PluginMain; }
        }

        public override bool MenuEnabled
        {
            get { return true; }
        }

        public override IList<string> MenuPath
        {
            get { return null; }
        }

        public override bool MenuVisible
        {
            get { return true; }
        }

        public override string PageName
        {
            get { return PluginView.GetLocalizedString("ActivityPageTitleText"); }
        }

        public override void ShowPage(string bookmark)
        {
            if (m_Control != null)
            {
                m_Control.DetailPageVisible = true;
            }
            m_Visible = true;
        }

        public override ZoneFiveSoftware.Common.Visuals.IPageStatus Status
        {
            get { return null; }
        }

        public override void ThemeChanged(ITheme visualTheme)
        {
            if (m_Control != null)
            {
                m_Control.ThemeChanged(visualTheme);
            }
        }

        public override string Title
        {
            get { return PluginView.GetLocalizedString("ActivityPageTitleText"); }
        }

        public override void UICultureChanged(CultureInfo culture)
        {
            if (m_Control != null)
            {
                m_Control.UICultureChanged(culture);
            }
        }

#endregion

        private DistributionDetailsControl m_Control = null;
        private IDailyActivityView m_DailyActivityView = null;
        private bool m_Visible = false;
    }
}
